home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / misc / emu / arosdev.lha / AROS / scripts / gendef.awk < prev    next >
Text File  |  1996-09-12  |  1KB  |  57 lines

  1. function strip(string)
  2. {
  3.     string=substr(string,match(string,/[^ \t|]/))
  4.     return string;
  5. }
  6.  
  7. function special(name)
  8. {
  9.     if(name=="Forbid"||name=="Permit"||name=="Disable"||name=="Enable"||
  10.        name=="ObtainSemaphore"||name=="ObtainSemaphoreShared"||
  11.        name=="ReleaseSemaphore"||name=="Switch")
  12.     return "P";
  13.     if(name=="Supervisor")
  14.     return "S";
  15.     return "";
  16. }
  17.  
  18. BEGIN        {
  19.         FS="[,()]*";
  20.         body="";
  21.         }
  22. /__AROS_LH/ {
  23.         head="#define " strip($3) "(";
  24.         body=special(strip($3)) "(" strip($2) ", " strip($3) ", \\\n";
  25.         cnt=0;
  26.         next;
  27.         }
  28. /__AROS_LA/ {
  29.         if(cnt)
  30.             head=head ", ";
  31.         head=head strip($3);
  32.         body=body " __AROS_LA(" $2 "," $3 "," $4 "), \\\n";
  33.         cnt++;
  34.         next;
  35.         }
  36. /SYNOPSIS/  {    next;    }
  37. /LOCATION/  {    next;    }
  38.         {
  39.         if($0==""||$0=="|")
  40.             next;
  41.         if(body!="")
  42.         {
  43.             string=head ") \\\n" "__AROS_LC" cnt body \
  44.                "           " strip($1) "," $2 "," $3 "," $4 ")\n";
  45.             head="";
  46.             body="";
  47.             all[$3+0]=string;
  48.             if($3>max)
  49.             max=$3;
  50.         }
  51.         }
  52. END        {
  53.         for(i=5;i<=max;i++)
  54.             if(all[i]!="")
  55.             print all[i];
  56.         }
  57.